Skip to content

🐛 Fix recordings, do not store assets if they do not have an MRN or an id#5935

Merged
preslavgerchev merged 1 commit intomainfrom
preslav/wip-recordings
Sep 19, 2025
Merged

🐛 Fix recordings, do not store assets if they do not have an MRN or an id#5935
preslavgerchev merged 1 commit intomainfrom
preslav/wip-recordings

Conversation

@preslavgerchev
Copy link
Copy Markdown
Contributor

@preslavgerchev preslavgerchev commented Sep 12, 2025

  • Do not store assets without MRN or an id. We do not know what to do with those assets, so best to not just store them at all
  • Adding an asset by MRN after it's been added by id will now overwrite the asset
  • Ensure runtime.AssetUpdated gets called when we update the asset's MRN. Recordings that get sent upstream are only retrieved by MRN so we need to ensure that every time the MRN gets updated we need to update the recording
  • Some tests for adding an asset to a recording. We should start adding more of those to make the recording bug-free now that we are storing it upstream

To test, first run make cnquery/install, then run this qp:

packs:
  - uid: rec-test
    name: Recording test
    filters:
      - mql: asset.family.contains("unix")
    queries:
      - uid: packages
        title: packages
        mql: packages
      - uid: users
        title: users
        mql: users
      - uid: services
        title: services
        mql: services
~/go/bin/cnquery scan -f qp.yaml --record recording.json

Then load the recording:

~/go/bin/cnquery shell --use-recording recording.json

Accessing packages, users and services should be instant

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 12, 2025

Test Results

4 402 tests  +3   4 398 ✅ +3   2m 20s ⏱️ -2s
  409 suites ±0       4 💤 ±0 
   30 files   ±0       0 ❌ ±0 

Results for commit 90c3174. ± Comparison against base commit 297a9aa.

♻️ This comment has been updated with latest results.

…n id.

Signed-off-by: Preslav <preslav@mondoo.com>
@preslavgerchev preslavgerchev changed the title 🐛 Fix recordings. 🐛 Fix recordings, do not store assets if they do not have an MRN or an id Sep 12, 2025
Copy link
Copy Markdown
Contributor

@vjeffrey vjeffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank u! works beautifully!

@preslavgerchev preslavgerchev merged commit e20944f into main Sep 19, 2025
17 checks passed
@preslavgerchev preslavgerchev deleted the preslav/wip-recordings branch September 19, 2025 19:47
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants